<?php
/**
 * wap 2.0 用户中心－地址编辑－异步获取地址信息
 */


include_once(ROOT_PATH . 'includes/cls_json.php');
$json = new JSON;

// 获取类型（市/区）
$type = empty($_REQUEST['type']) ? '' : trim($_REQUEST['type']);

$id = empty($_REQUEST['id']) ? 0 : trim($_REQUEST['id']);

if (!$type || !$id)
{
	return false;
}

// 返回市
if ($type == 'city' )
{
	$city_list = $mem->getCache('sexmall_citys_'.$id, true);
	if (empty($city_list) || !is_array($city_list))
	{
		$city_list = $mInterface->getShopArea($id);
		$mem->addCache('sexmall_citys_'.$id, $city_list, 0, true);
	}
	die($json->encode($city_list));
}
// 返回区
else if ($type == 'district')
{
	$district_list = $mem->getCache('sexmall_district_'.$id, true);
	if (empty($district_list) || !is_array($district_list))
	{
		$district_list = $mInterface->getShopArea('', $id);
		$mem->addCache('sexmall_district_'.$id, $district_list, 0, true);
	}
	die($json->encode($district_list));
}
// 返回街道
else if ($type == 'street')
{
	$street_list = $mem->getCache('sexmall_street_'.$id, true);
	if (empty($district_list) || !is_array($street_list))
	{
		$street_list = $mInterface->getShopAreaNew('', '', $id);
		$mem->addCache('sexmall_street_'.$id, $street_list, 0, true);
	}
	die($json->encode($street_list));
}